const _ = require('lodash');
const fp = require('lodash/fp');

const object = { a: [{ b: { c: 3 } }] };
_.update(object, 'a[0].b.c', function(n) { return n * n; })
console.log(object.a[0].b.c);

_.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
console.log(object.x[0].y.z);

const newObj = fp.update('a[0].b.c', function(n) { return n - 1; }, object);
console.log('after fp.update:', object.a[0].b.c);
console.log('after fp.update, newObj:', newObj.a[0].b.c);
